
function formSubmit(obj){
	layer.load(1);
	var content=$(obj);
	content.parents("form").submit();
}

function initPage(dataInfo){
	var basePath = $("#basePath").val();
	$("select:not([data-address])").each(function(){
		$(this).append("<option value=''>---请选择---</option>");
		
	});
	
	$("select[data-type='129Select']").each(function(){
		var options = "";
		options+="<option value='1'>是</option>";
		options+="<option value='2'>否</option>";
		options+="<option value='9'>-</option>";
		$(this).append(options);
	});
	
	$("select[data-type='localDRGsRiskGroup']").each(function(){
		var options = "";
		options+="<option value='1'>1级</option>";
		options+="<option value='2'>2级</option>";
		options+="<option value='3'>3级</option>";
		options+="<option value='4'>4级</option>";
		options+="<option value='5'>5级</option>";
		
		$(this).append(options);
	});
	
	
	
	$("select").each(function(){
		$(this).change(function(){
	   		var eventObj = $(this);
	   		var nameObjName = eventObj.attr("name").replace("Code", "Name");
	   		
	   		if(eventObj.val()!=""){
	   			var name=eventObj.find("option:selected").text();
	   			eventObj.next("input[name='"+nameObjName+"']").val(name);
	   		}else{
	   			eventObj.next("input[name='"+nameObjName+"']").val("");
	   		}
	   });
	});
	
	$("input[type='radio']").each(function(){
		$(this).click(function(){
			 $(this).nextAll("input[name='"+$(this).attr("name").replace("Code", "Name")+"']").val($(this).attr("title"));
		});
		$(this).dblclick(function(){
			$(this).removeAttr("checked");
			$(this).nextAll("input[name='"+$(this).attr("name").replace("Code", "Name")+"']").val(null);
		});
	});
	
	if(dataInfo){
		radioValue("whetherDRGsManageCode",dataInfo.whetherDRGsManageCode,
				"whetherDRGsManageName",dataInfo.whetherDRGsManageName);
		
		selectValue("localDRGsRiskGroupCode",dataInfo.localDRGsRiskGroupCode,
				"localDRGsRiskGroupName",dataInfo.localDRGsRiskGroupName);
		
		radioValue("whetherMDTCode",dataInfo.whetherMDTCode,
				"whetherMDTName",dataInfo.whetherMDTName);
		var localDRGsShow = null;
		if(dataInfo.localDRGsCode){
			localDRGsShow = dataInfo.localDRGsCode+"["+dataInfo.localDRGsName+"]";
		}
		$("input[name='localDRGsShow']").val(localDRGsShow);
		$("input[name='localDRGsGroupWeight']").val(dataInfo.localDRGsGroupWeight);
		$("input[name='localDRGsGroupTotalWeight']").val(dataInfo.localDRGsGroupTotalWeight);
		$("input[name='icuNumberOfDay']").val(dataInfo.icuNumberOfDay);
		$("input[name='useVentilatorNumberOfHour']").val(dataInfo.useVentilatorNumberOfHour);
	}
	/*initProeesureSores(dataInfo);
	initFallDown(dataInfo);
	initPhysicalConstraint(dataInfo);
	initObstetricDelivery(dataInfo);*/
	/*var validator = $("#nurseQualityControlInfoForm").validate({
		errorElement: "title",
		ignoreTitle: true,
		submitHandler : function(){
			return true;
		},
		rules:{
			'physicalConstraintInfo.physicalConstraintDay': {
				digits:true,
            	range:[1,1000]
            }
			
		},
		
	});*/
}

function selectValue(codeName,codeValue,nameName,nameValue){
	if(codeValue){
	  	var selectedIndex = $("select[name='"+codeName+"'] option[value='"+codeValue+"']").first().index();
		if (selectedIndex == -1) {
			var option = "<option selected value='" + codeValue + "'>" + nameValue + "</option>";
			$("select[name='"+codeName+"']").append(option);
		} else {
			$("select[name='"+codeName+"']").get(0).selectedIndex = selectedIndex;
		}
	}
	$("select[name='"+codeName+"']").next("input[name='"+nameName+"']").val(nameValue);
}

function radioValue(codeName,codeValue,nameName,nameValue){
	if(codeValue){
		$("input[name='"+codeName+"'][value='"+codeValue+"']").attr("checked",true);
	}
	$("input[name='"+nameName+"']").val(nameValue);
}